module timestep
use technical
use df_dt
implicit none
public 
contains
!--------------------------------------------
subroutine RK2(y,tt,df,deltat)
use cdata
implicit none
real,dimension(ndim) :: y,df
real :: tt,deltat
real,dimension(ndim) :: k1,k2
call eval_rhs(y,tt,df)
k1=deltat*df
call eval_rhs(y+k1/2.,tt+deltat/2,df)
k2=deltat*df
y=y+k2
end subroutine
!--------------------------------------------
subroutine RK4(y, tt, df, deltat)
use cdata
implicit none
real,dimension(ndim) :: y, df
real :: tt, deltat
real,dimension(ndim) :: k1, k2, k3, k4

!k1
call eval_rhs(y, tt, df)
k1 = deltat*df
!k2
call eval_rhs(y+0.5*k1, tt+0.5*deltat, df)
k2 = deltat*df
!k3
call eval_rhs(y+0.5*k2, tt+0.5*deltat, df)
k3 = deltat*df
!k4
call eval_rhs(y+k3, tt+deltat, df)
k4 = deltat*df

y = y + 1./6.*k1 + 1./3.*k2 + 1./3.*k3 + 1./6.*k4

end subroutine
!============================================
end module timestep
